define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'conference/conf/index' + location.search,
                    add_url: 'conference/conf/add',
                    edit_url: 'conference/conf/edit',
                    del_url: 'conference/conf/del',
                    multi_url: 'conference/conf/multi',
                    import_url: 'conference/conf/import',
                    table: 'activity_conf',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id')},
                        {field: 'name', title: __('Name'), operate: 'LIKE'},
                        {field: 'serial', title: __('Serial')},
                        {field: 'detail', title: __('Detail'), operate: 'LIKE'},
                        {field: 'createTime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        {field: 'startTime', title: __('Starttime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
                        {field: 'endTime', title: __('Endtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
                        {field: 'repeat', title: __('Repeat'), searchList: {"n":__('Repeat n'),"d":__('Repeat d'),"w":__('Repeat w'),"s":__('Repeat s'),"m":__('Repeat m')}, formatter: Table.api.formatter.normal},
                        {field: 'meetingType', title: __('Meetingtype'), searchList: {"0":__('Meetingtype 0'),"1":__('Meetingtype 1')}, formatter: Table.api.formatter.normal},
                        {field: 'normalPassword', title: __('Normalpassword'), operate: 'LIKE'},
                        {field: 'mainPassword', title: __('Mainpassword'), operate: 'LIKE'},
                        {field: 'option', title: __('Option'), operate: 'LIKE'},
                        {field: 'admin_id', title: __('Admin_id')},
                        {field: 'status', title: __('Status'), searchList: {"0":__('Status 0'),"1":__('Status 1')}, formatter: Table.api.formatter.status},
                        {field: 'company_id', title: __('Company_id')},
                        {field: 'platform_id', title: __('Platform_id')},
                        {field: 'platform_type', title: __('Platform_type')},
                        {field: 'platform_status', title: __('Platform_status')},
                        {field: 'isself', title: __('Isself')},
                        {field: 'mainVideo', title: __('Mainvideo'), searchList: {"0":__('Mainvideo 0'),"1":__('Mainvideo 1')}, formatter: Table.api.formatter.normal},
                        {field: 'mainAudio', title: __('Mainaudio'), searchList: {"0":__('Mainaudio 0'),"1":__('Mainaudio 1')}, formatter: Table.api.formatter.normal},
                        {field: 'participantVideo', title: __('Participantvideo'), searchList: {"0":__('Participantvideo 0'),"1":__('Participantvideo 1')}, formatter: Table.api.formatter.normal},
                        {field: 'participantAudio', title: __('Participantaudio'), searchList: {"0":__('Participantaudio 0'),"1":__('Participantaudio 1')}, formatter: Table.api.formatter.normal},
                        {field: 'mode', title: __('Mode'), searchList: {"freeCamera":__('Mode freecamera'),"mainBroadcast":__('Mode mainbroadcast'),"mainCamera":__('Mode maincamera')}, formatter: Table.api.formatter.normal},
                        {field: 'lock', title: __('Lock'), searchList: {"0":__('Lock 0'),"1":__('Lock 1')}, formatter: Table.api.formatter.normal},
                        {field: 'entry_number', title: __('Entry_number')},
                        {field: 'entry_time', title: __('Entry_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
                        {field: 'duration', title: __('Duration')},
                        {field: 'advanced_mode_id', title: __('Advanced_mode_id')},
                        {field: 'share_image', title: __('Share_image'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},
                        {field: 'create_type', title: __('Create_type'), operate: 'LIKE'},
                        {field: 'cover', title: __('Cover'), operate: 'LIKE'},
                        {field: 'sketch', title: __('Sketch'), operate: 'LIKE'},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});